package com.mz.mattress.admin.api.merchant;

import com.mz.mattress.admin.api.req.BlackSaveReq;
import com.mz.mattress.admin.api.resp.SaveDeviceResp;
import com.mz.mattress.admin.service.BlackItemService;
import com.mz.mattress.api.common.Constants;
import com.mz.mattress.api.common.Result;
import com.mz.mattress.api.entity.BlackItem;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

@Slf4j
@RestController
@RequestMapping(Constants.MERCHANT_PATH + "blackItem")
public class BlackItemController {

    @Autowired
    private BlackItemService blackItemService;

    @GetMapping("/{id}")
    public Result<BlackItem> detail(@PathVariable Integer id) {
        return blackItemService.getById(id);
    }

    @PostMapping
    public Result add(@RequestBody BlackItem blackItem) {
        return blackItemService.add(blackItem);
    }

    @PostMapping(value = "/save")
    public Result<SaveDeviceResp> save(@RequestBody BlackSaveReq req) {
        return blackItemService.save(req);
    }

    @PutMapping
    public Result update(@RequestBody BlackItem blackItem) {
        return blackItemService.updateById(blackItem);
    }

    @DeleteMapping
    public Result delete(@RequestBody Set<Integer> ids) {
        return blackItemService.deleteByIds(ids);
    }

}
